package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.PayAccountMapper;
import com.xyy.saas.payment.dao.model.PayAccount;
import com.xyy.saas.payment.service.PayAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PayAccountServiceImpl implements PayAccountService {

    @Autowired
    private PayAccountMapper payAccountMapper;

    @Override
    public int createAccount(PayAccount payAccount) {
        if(null == payAccount) {
            return 0;
        }
        return payAccountMapper.insertSelective(payAccount);
    }

    @Override
    public String getAccountIdByBusiness(String businessIdType, String businessUserId){
        return payAccountMapper.getAccountIdByBusiness(businessIdType, businessUserId);
    }

    @Override
    public PayAccount selectByBusiness(String businessIdType, String businessUserId) {
        return payAccountMapper.selectByBusiness(businessIdType, businessUserId);
    }

    @Override
    public PayAccount getPayAccountByAccountId(String accountId){
        return payAccountMapper.selectByAccountId(accountId);
    }

    @Override
    public String getBusinessUserIdByAccountId(String accountId) {
        return getPayAccountByAccountId(accountId).getBusinessUserId();
    }

    @Override
    public String getBusinessUserIdByAccountId2(String accountId) {
        PayAccount payAccount = getPayAccountByAccountId(accountId);
        if (payAccount == null) {
            return null;
        }
        return payAccount.getBusinessUserId();
    }

    @Override
    public int updateByPrimaryKeySelective(PayAccount record) {
        return payAccountMapper.updateByPrimaryKeySelective(record);
    }
}
